package world.snowcrystal.autoconfigure;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import world.snowcrystal.client.SnowCrystalApiClient;



@Configuration
@EnableConfigurationProperties(ApiClientProperties.class)
public class ApiClientAutoConfiguration {

    private final ApiClientProperties properties;

    public ApiClientAutoConfiguration(ApiClientProperties properties) {
        this.properties = properties;
    }

    @Bean
    public SnowCrystalApiClient snowCrystalApiClient() {
        return new SnowCrystalApiClient(new RestTemplate(), properties.getAccessKey(), properties.getSecretKey());
    }
}
